#include <algorithm>
#include <cstdio>

const int N = 100;
int n, m;
int e_cnt, heads[N], dep[N], ans[N], f[N], L[N], R[N];

struct Edge {
  int v, nxt, l, r;
} e[N << 1];

inline void add(int u, int v, int l, int r) {
  e[++e_cnt].v = v, e[e_cnt].nxt = heads[u], heads[u] = e_cnt, e[e_cnt].l = l,
  e[e_cnt].r = r;
}

void dfs(int x, int fa) {
  for (int i = heads[x], v; i; i = e[i].nxt) {
    if ((v = e[i].v) != fa) {
      f[v] = x;
      L[v] = e[i].l, R[v] = e[i].r;
      dep[v] = dep[x] + 1;
      dfs(v, x);
    }
  }
}

inline void solve(int x, int y) {
  int min = 0, max = 0x3fffffff, len = dep[x] + dep[y];
  if (dep[x] < dep[y]) std::swap(x, y);
  while (dep[x] > dep[y])
    max = std::min(max, R[x]), min = std::max(min, L[x]), x = f[x];
  while (x != y) {
    max = std::min(max, R[x]), min = std::max(min, L[x]);
    max = std::min(max, R[y]), min = std::max(min, L[y]);
    x = f[x], y = f[y];
  }
  for (int i = min; i <= max; ++i)
    ans[i] = std::max(ans[i], len - (dep[x] << 1));
}

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen64("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen64("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("speed.in", "r", stdin);
  freopen("speed.out", "w", stdout);
#endif
#endif

  scanf("%d%d", &n, &m);
  for (int i = 1, u, v, l, r; i < n; ++i) {
    scanf("%d%d%d%d", &u, &v, &l, &r);
    add(u, v, l, r), add(v, u, l, r);
  }
  for (int i = 1; i <= n; ++i) {
    if (!dep[i]) dep[i] = 1, dfs(1, 1);
  }
  for (int i = 1; i <= n; ++i)
    for (int j = i + 1; j <= n; ++j) solve(i, j);
  for (int i = 1, q; i <= m; ++i) scanf("%d", &q), printf("%d\n", ans[q]);
  return 0;
}